/*
 * © 2010 Autodata Solutions Company. All Rights Reserved
 * This source code is the confidential and proprietary information of Autodata Solutions Company.
 * The user shall not, in whole or in part, copy, publish, disclose or make any use of this source code
 * without the prior written consent of Autodata Solutions Company.
 *
 * File: ca/autotrader/compare/widgets/PageToolbar.js
 * Purpose: Provides custom implimintation of the pages toolbar widget.
 *
 * Namespace: net.autodata.compare.toolbars
 * Requires:ExtJS,
 *          ASC library - net/autodata/ascjs-ext-debug.js
 */
Ext.ns('net.autodata.compare.toolbars');
(function() {
    /**
    * Page header toolbar
    * @class PageToolbar
    * @extends Ext.Toolbar
    * @namespace net.autodata.compare.toolbars
    */
    var PageToolbar = Ext.extend(Ext.Toolbar, {
        /**
        * @property view
        * @type Object
        */
        view: undefined,

        /**
        * @property width
        * @type int
        */
        width: 790,

        /**
        * @property width
        * @type int
        */
        height: 33,

        /**
        * @property cls
        * @type String
        */
        cls: 'page-toolbar',

        /**
        * @property shownav
        * @type bool
        */
        shownav: true,

        /**
        * @property forceLayout
        * @type bool
        */
        forceLayout: true,

        /**
        * @method constructor
        * @param {Object} cfg
        */
        constructor: function(cfg) {
            PageToolbar.superclass.constructor.call(this, cfg);
        },

        initComponent: function() {
            PageToolbar.superclass.initComponent.apply(this, arguments);

            var view = this.getView();
            view.init(this);
        },

        /**
        * Gets the page toolbar's view
        */
        getView: function() {
            if (!this.view) {
                this.view = new net.autodata.compare.toolbars.PageToolbarView(this.viewCfg);
            }

            return this.view;
        },

        //Event Handlers,

        /**
        * Toolbar's on render event handler.
        * @method onRender
        * @private
        */
        onRender: function() {
            PageToolbar.superclass.onRender.apply(this, arguments);

            var view = this.getView();
            view.render();
        },

        /**
        * Toolbars on destroy event handler.
        * @method onDestroy
        * @private
        */
        onDestroy: function() {
            delete this.data;
            this.removeAll(true);
            PageToolbar.superclass.onDestroy.apply(this, arguments);
        }
    });

    net.autodata.compare.toolbars.PageToolbar = PageToolbar;
})();
